count number of times a character occurs in the given string